package com.upay.android.client.adapter;

import java.util.List;

import android.app.Activity;
import android.graphics.Color;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.TextView;

import com.upay.android.client.R;
import com.upay.domain.account.User;


public class AvailableUserArrayAdapter extends ArrayAdapter<User> {
	
	/* ---- Instance Variables ---- */
	private Activity context = null;
	private List<User> users = null;

	/* ---- Constructors ---- */
	public AvailableUserArrayAdapter(Activity context, List<User> users) {
		super(context, R.layout.availableuserrowlayout, users);
		this.context = context;
		this.users = users;
	}
	
	/* ---- Business Methods ---- */
	
	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		View view = null;
		
		if (convertView == null) {
			LayoutInflater inflator = context.getLayoutInflater();
			view = inflator.inflate(R.layout.availableuserrowlayout, null);
			final ViewHolder viewHolder = new ViewHolder();
			viewHolder.firstName = (TextView) view.findViewById(R.id.group_user_row_firstname);
			viewHolder.lastName = (TextView) view.findViewById(R.id.group_user_row_lastname);
			view.setTag(viewHolder);
		} else {
			view = convertView;
		}
		ViewHolder holder = (ViewHolder) view.getTag();
		User user = users.get(position);
		holder.firstName.setText(user.getFirstName());
		holder.firstName.setTextColor(Color.rgb(51, 181, 229));
		holder.firstName.setTextSize(18);
		holder.lastName.setText(user.getLastName());
		holder.lastName.setTextColor(Color.rgb(51, 181, 229));
		holder.lastName.setTextSize(18);
		return view;
	}
	

	static class ViewHolder {
		protected TextView firstName;
		protected TextView lastName;
	}


	/* ---- Getters and Setters ---- */

	/**
	 * @return the context
	 */
	public Activity getContext() {
		return context;
	}



	/**
	 * @param context the context to set
	 */
	public void setContext(Activity context) {
		this.context = context;
	}

	/**
	 * @return the users
	 */
	public List<User> getUsers() {
		return users;
	}

	/**
	 * @param users the users to set
	 */
	public void setUsers(List<User> users) {
		this.users = users;
	}

	

	
	
	

}
